import Message from './components/Message.vue'
import { createApp } from 'vue'
export type Messagetype = 'success' | 'error' | 'default'
const createMessage = (message: string, types: Messagetype, timeout = 2000) => {
  const messageInstance = createApp(Message, {
    types,
    message
  })// 两个参数一个是组件，一个是组件的props

  const mountNode = document.createElement('div')
  document.body.appendChild(mountNode)
  messageInstance.mount(mountNode)
  setTimeout(() => {
    messageInstance.unmount(mountNode)
    document.body.removeChild(mountNode)
  }, timeout)
}
export default createMessage
// 一句话，先来创建应用，然后去在文档中创建你讲啦想要挂载的节点，最后在去挂载mounted，
// 当你想把一个组件变为一个函数去调用的时候就去
